import threading

class MyThread(threading.Thread):
    thread_id = ''
    args = ''
    act = ''
    func_name = ''
    classify = ''

    def __init__(self, thread_id, classify, func_name, args={}, act=''):
        threading.Thread.__init__(self)
        self.thread_id = thread_id
        self.classify = classify
        self.func_name = func_name
        self.args = args
        self.act = act

    def run(self):
        threadLock = threading.Lock()
        #print ("开启线程： " + self.name)
        # 获取锁，用于线程同步
        threadLock.acquire()
        exec("from "+ self.classify +"." + self.func_name + " import *\n\t")
        exec(self.func_name + " = " + self.func_name + "()")
        exec(self.func_name + ".multirun(self.args)")
        # 释放锁，开启下一个线程
        threadLock.release()